import React from "react";
import CreateContextGrandSon from "./CreateContextGrandSon.jsx";
import { Consumer } from "./Context.js";
class CreateContextSon extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
        child
        <Consumer>
          {(user) => {console.log(user);return(
            <div
              style={{
                border: "1px solid blue",
                padding: "8px"
              }}
            >
              <p>
                子组件。获取父组件的值:{user.name} | age:{user.age}
              </p>
              {/* 孙组件内容 */}

              <CreateContextGrandSon></CreateContextGrandSon>
            </div>
          )}}
        </Consumer>
      </div>
    );
  }
}
export default CreateContextSon;
